package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mapper.BoatMapper;
import com.example.pojo.Boat;
import com.example.service.BoatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BoatServiceImpl extends ServiceImpl<BoatMapper, Boat> implements BoatService {
    @Autowired
    private BoatMapper boatMapper;

    @Override
    public List<Boat> selectAllBoat(String beginningName,String destinationName, Integer start, Integer pageSize) {//条件+分页查询轮船票信息
        List<Boat> boats = boatMapper.selectAllBoat(beginningName, destinationName, start, pageSize);
        return boats;
    }

    @Override
    public int count(String beginningName,String destinationName) {//条件查询轮船票信息数量
        int count = boatMapper.count(beginningName, destinationName);
        return count;
    }

    @Override
    public int addBoat(Boat boat) {//添加轮船票信息
        int row= boatMapper.insert(boat);
        return row;
    }

    @Override
    public int deleteBoat(Integer id) {//删除轮船票信息
        int row = boatMapper.deleteById(id);
        return row;
    }

    @Override
    public Boat selectByIdBoat(Integer id) {//根据id查询轮船票信息
        Boat boat = boatMapper.selectById(id);
        return boat;
    }

    @Override
    public int updateBoat(Boat boat) {//修改轮船票信息
        int row = boatMapper.updateById(boat);
        return row;
    }
}
